<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #canvas {
        border: 1px solid;
      }
    </style>
  </head>

  <body>
    <img id="source" src="./image.jpg"
    width="300" height="227">
    <canvas width="400" height="400" id="canvas"> 请升级你的服务器 </canvas>
    <script>
      var canvas = document.querySelector("#canvas");
      var context = canvas.getContext("2d");
      var image = document.getElementById('source');
      var img = new Image()
      img.src = './image.jpg'
      // img.onload = function () {
      //   context.drawImage(image, 0, 0, image.width, image.height);
      //   context.fillText('水印', 100, 200);
      // }
      window.onload = function () {
        context.drawImage(image, 0, 0, image.width, image.height);
        context.fillText('水印', 100, 200);
      }
    </script>
  </body>
</html>
